// 用户管理模块接口
import request from '@/utils/request'
import type {UserResponseData,User,ALLRoleResponseData,SetRoleData} from './type'
// 枚举地址
enum API{
  ALLUSER_URL='/admin/acl/user/',
  ADDUSER_URL='/admin/acl/user/save',
  UPDATEUSER_URL='/admin/acl/user/update',
  ALLROLE_URL='/admin/acl/user/toAssign/',
  SETROLE_URL='/admin/acl/user/doAssignRole',
  DELETEUSER_URL='/admin/acl/user/remove/',
  DELETEALLUSER_URL='/admin/acl/user/batchRemove',
}
// 获取全部用户接口
export const reqUserInfo = (page:number,limit:number,username:string)=>request.get<any,UserResponseData>(API.ALLUSER_URL+`${page}/${limit}/?username=${username}`)
// 新增用户、修改用户
export const reqAddOrUpdateUser = (data:User)=>{
  if(data.id){
    return request.put<any,any>(API.UPDATEUSER_URL,data)
  }else{
    return request.post<any,any>(API.ADDUSER_URL,data)
  }
}
// 获取全部职位 以及当前用户已有职位
export const reqAllRole = (userId:number)=>request.get<any,ALLRoleResponseData>(API.ALLROLE_URL+userId)
// 分配职位接口
export const reqSetUserRole = (data:SetRoleData)=>request.post<any,any>(API.SETROLE_URL,data)
// 删除单个用户
export const reqRemoveUser = (userId:number)=>request.delete<any,any>(API.DELETEUSER_URL+userId)
// 批量删除
export const reqRemoveAllUser = (idList:number[])=>request.delete<any,any>(API.DELETEALLUSER_URL,{data:idList})
